package com.example.phoneshop.controller;

import com.example.phoneshop.entity.User;
import com.example.phoneshop.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping(value = "test")
public class TestController {
    private final UserService userService;

    @Autowired
    public TestController(UserService userService) {
        this.userService = userService;
    }


    @RequestMapping(value = "test1", method = RequestMethod.GET)
    public ModelAndView testUser(User user) {
        ModelAndView modelAndView = new ModelAndView("test/test");
        user = userService.findUserByPhone("13739497421");
        modelAndView.addObject("user", user);
        return modelAndView;
    }



}












